# -*- coding: utf-8 -*-

'''获取当前日期前后N天或N月的日期'''

from time import strftime, localtime
from datetime import timedelta, date, time
import calendar

year = strftime("%Y", localtime())
mon = strftime("%m", localtime())
day = strftime("%d", localtime())
hour = strftime("%H", localtime())
min = strftime("%M", localtime())
sec = strftime("%S", localtime())


class daylink :


    def today(self):
        '''''
        get today,date format="YYYY-MM-DD"
        '''''
        return date.today()


    def todaystr(self):
        '''
        get date string, date format="YYYYMMDD"
        '''
        return year + mon + day


    def datetime(self):
        '''''
        get datetime,format="YYYY-MM-DD HH:MM:SS"
        '''
        return strftime("%Y-%m-%d %H:%M:%S", localtime())


    def datetimestr(self):
        '''''
        get datetime string
        date format="YYYYMMDDHHMMSS"
        '''
        return year + mon + day + hour + min + sec


    def get_day_of_day(self,n=0):
        '''''
        if n>=0,date is larger than today
        if n<0,date is less than today
        date format = "YYYY-MM-DD"
        '''
        if (n < 0):
            n = abs(n)
            return date.today() - timedelta(days=n)
        else:
            return date.today() + timedelta(days=n)

    def time_cmp(self,first_time, second_time):

        print(first_time)

        print(second_time)

        return int(time.strftime("%H%M%S", first_time)) - int(time.strftime("%H%M%S", second_time))


if __name__ == "__main__":
    print(daylink().get_day_of_day(-90))